object dlgSelectAbonent: TdlgSelectAbonent
  Left = 407
  Top = 301
  ActiveControl = lcbTowns
  BorderStyle = bsDialog
  Caption = #1042#1099#1073#1086#1088' '#1072#1073#1086#1085#1077#1085#1090#1072
  ClientHeight = 117
  ClientWidth = 569
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poMainFormCenter
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object gbAddress: TGroupBox
    Left = 0
    Top = 0
    Width = 569
    Height = 117
    Align = alClient
    TabOrder = 0
    object Label6: TLabel
      Left = 332
      Top = 23
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1051#1080#1094#1077#1074#1086#1081' '#1089#1095#1077#1090
    end
    object Label1: TLabel
      Left = 3
      Top = 25
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1053#1072#1089'.'#1087#1091#1085#1082#1090
    end
    object Label2: TLabel
      Left = 3
      Top = 47
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1059#1083#1080#1094#1072
    end
    object Label3: TLabel
      Left = 3
      Top = 69
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1044#1086#1084
    end
    object Label4: TLabel
      Left = 206
      Top = 69
      Width = 26
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1050#1074'.'
    end
    object Label5: TLabel
      Left = 332
      Top = 46
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1058#1077#1083#1077#1092#1086#1085
    end
    object Label7: TLabel
      Left = 3
      Top = 91
      Width = 69
      Height = 13
      Alignment = taRightJustify
      AutoSize = False
      Caption = #1060#1048#1054
    end
    object lcbTowns: TDBLookupComboboxEh
      Left = 80
      Top = 22
      Width = 230
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      EditButtons = <>
      Flat = True
      KeyField = 'CODE'
      ListField = 'NAME'
      ListSource = dsc_Towns
      TabOrder = 0
      Visible = True
      OnChange = lcbTownsChange
      OnCloseUp = lcbTownsCloseUp
      OnEnter = lcbTownsEnter
      OnKeyPress = lcbTownsKeyPress
    end
    object lcbStreets: TDBLookupComboboxEh
      Left = 80
      Top = 44
      Width = 230
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      EditButtons = <>
      Flat = True
      KeyField = 'CODE'
      ListField = 'STREET'
      ListSource = dsc_Streets
      TabOrder = 1
      Visible = True
      OnChange = lcbStreetsChange
      OnCloseUp = lcbTownsCloseUp
      OnEnter = lcbTownsEnter
      OnKeyPress = lcbTownsKeyPress
    end
    object lcbBuildings: TDBLookupComboboxEh
      Left = 80
      Top = 66
      Width = 78
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      EditButtons = <>
      Flat = True
      KeyField = 'ID'
      ListField = 'HOUSE_NUM'
      ListSource = dsc_Houses
      TabOrder = 2
      Visible = True
      OnChange = lcbBuildingsChange
      OnCloseUp = lcbTownsCloseUp
      OnEnter = lcbTownsEnter
      OnKeyPress = lcbTownsKeyPress
    end
    object lcbApparts: TDBLookupComboboxEh
      Left = 235
      Top = 66
      Width = 75
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      EditButtons = <>
      Flat = True
      KeyField = 'FLAT_NUM'
      ListField = 'FLAT_NUM'
      ListSource = dsc_Apparts
      TabOrder = 3
      Visible = True
      OnChange = lcbAppartsChange
      OnCloseUp = lcbTownsCloseUp
      OnEnter = lcbTownsEnter
      OnExit = lcbClientNameExit
      OnKeyPress = lcbTownsKeyPress
    end
    object dbeNls: TDBEditEh
      Left = 409
      Top = 21
      Width = 146
      Height = 19
      AlwaysShowBorder = True
      EditButtons = <>
      Flat = True
      TabOrder = 5
      Visible = True
      OnChange = dbeNlsChange
      OnEnter = dbeNlsEnter
      OnExit = dbeNlsExit
      OnKeyPress = lcbTownsKeyPress
    end
    object dbePhone: TDBEditEh
      Left = 409
      Top = 43
      Width = 146
      Height = 19
      AlwaysShowBorder = True
      EditButtons = <>
      Flat = True
      TabOrder = 6
      Visible = True
      OnChange = dbeNlsChange
      OnEnter = dbeNlsEnter
      OnExit = dbePhoneExit
      OnKeyPress = lcbTownsKeyPress
    end
    object bSelect: TBitBtn
      Left = 409
      Top = 66
      Width = 146
      Height = 41
      Caption = '  '#1042#1099#1073#1088#1072#1090#1100
      Enabled = False
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clGreen
      Font.Height = -16
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ModalResult = 1
      ParentFont = False
      TabOrder = 7
      OnClick = bSelectClick
      Glyph.Data = {
        36030000424D3603000000000000360000002800000010000000100000000100
        1800000000000003000000000000000000000000000000000000FFFFFFFFFFFF
        FFFFFFFFFFFFCCCCCC666967255344045D48045D48255344666967CCCCCCFFFF
        FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F5F56266630E6A3524D07A3FEE9E4C
        F6B34CF6B33FEE9E24D17B0E6A35626663F5F5F5FFFFFFFFFFFFFFFFFFF5F5F5
        3F4A3F209E383BD25E4BDF7700944A00944A43EC9A46E78C4BDF773BD35E209E
        383F4A3FF5F5F5FFFFFFFFFFFF63656229901835BD3639CB4E00944A0080002C
        B10000CD192FDB7533D46439CB4F35BD37299019636562FFFFFFCCCCCC1D5101
        37A80E37B52500944A0080000080000080002CB10000CD192CC74D31BF3B37B5
        2537A80F1D5101CCCCCC666766368F003AA10200944A00800000800000800000
        80000080002CB10000E97432B32438AB123AA102368F006667662F4024399500
        00800000800000800000800000CD190080000080000080002CB1003AA8103CA1
        033A9B003995002F4024173604388F0000800000800000800000CD1900CD1945
        AD1B00800000800000800000CD1947A0103E9706388F00173604173404388900
        519C1F00800000CD1900CD1956A92256AA2256AA220080000080002CB10000E9
        74519C1F3889001734042E3D243C860765A23965A63966A83966AA3966AC3966
        AC3966AC3966AC390080000080002CB10000E9743C86072E3D24666766367606
        79AB547AAD557AAF557AB1557BB2557BB2557BB2557BB2557AB1550080000080
        0000E97400E974666766CCCCCC1A3C017DA95B92B97694BB7794BC7794BD7794
        BD7794BD7794BD7794BC7794BB7700800000800000E974CCCCCCFFFFFF626462
        487325AEC999B4CEA0B4CEA0B4CFA0B4CFA0B4CFA0B4CFA0B4CEA0B4CEA0AEC9
        9900800000944A00E974FFFFFFF5F5F53F443C608143D1DFC6D9E5D0D9E5D0D9
        E5D0D9E5D0D9E5D0D9E5D0D1DFC66081433F443C00800000CD19FFFFFFFFFFFF
        F5F5F5626362334920A2B790E4EBDDF7F9F5F7F9F5E4EBDDA2B7903349206263
        62F5F5F5FFFFFF008000FFFFFFFFFFFFFFFFFFFFFFFFCCCCCC6667662D382420
        31102031102D3824666766CCCCCCFFFFFFFFFFFFFFFFFFFFFFFF}
    end
    object lcbClientName: TDBLookupComboboxEh
      Left = 80
      Top = 88
      Width = 230
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.ShowTitles = True
      DropDownBox.Sizable = True
      EditButtons = <>
      Flat = True
      KeyField = 'ID'
      ListField = 'NAME;is_active;G_LICSCHET'
      ListSource = dsc_Abonent
      TabOrder = 4
      Visible = True
      OnChange = lcbClientNameChange
      OnCloseUp = lcbTownsCloseUp
      OnDropDownBoxGetCellParams = lcbClientNameDropDownBoxGetCellParams
      OnEnter = lcbTownsEnter
      OnExit = lcbClientNameExit
      OnKeyPress = lcbTownsKeyPress
    end
  end
  object LocalTrans: TpFIBTransaction
    DefaultDatabase = MAINDM.pMainDatabase
    TimeoutAction = TARollback
    Left = 4
    Top = 8
  end
  object ds_Towns: TpFIBDataSet
    SelectSQL.Strings = (
      'select v.code, v.name'
      '  from vw_towns v'
      '  where v.local = 1'
      '  order by 2')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_TownsAfterOpen
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 136
    Top = 4
    oFetchAll = True
    object ds_TownsCODE: TFIBIntegerField
      FieldName = 'CODE'
    end
    object ds_TownsNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
  end
  object dsc_Towns: TDataSource
    DataSet = ds_Towns
    Left = 176
    Top = 8
  end
  object dsc_Streets: TDataSource
    DataSet = ds_Streets
    Left = 296
    Top = 8
  end
  object ds_Streets: TpFIBDataSet
    SelectSQL.Strings = (
      'select s.code, s.street from rstreets s'
      '  where s.town_id = :ptown_id'
      '    and exists(select 1 from buildings b, abonents a'
      '               where a.building_id = b.id'
      '                and b.street_id = s.code'
      '                and a.client_id > -1'
      
        '                and (a.is_active = 1 or coalesce(:pis_not_active' +
        ', 0) = 1))'
      '  order by 2')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_TownsAfterOpen
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 336
    Top = 8
    oFetchAll = True
    object ds_StreetsCODE: TFIBIntegerField
      FieldName = 'CODE'
    end
    object ds_StreetsSTREET: TFIBStringField
      FieldName = 'STREET'
      Size = 120
      EmptyStrToNull = True
    end
  end
  object dsc_Houses: TDataSource
    DataSet = ds_Houses
    Left = 260
    Top = 60
  end
  object ds_Houses: TpFIBDataSet
    SelectSQL.Strings = (
      'select b.id, b.house||coalesce('#39' '#1082'.'#39'||b.corps, '#39#39') as house_num'
      '  from buildings b'
      '  where b.street_id = :pstreet_id'
      '    and exists(select 1 from abonents a'
      '               where a.building_id = b.id'
      '                 and a.client_id > -1'
      
        '                 and (a.is_active = 1 or coalesce(:pis_not_activ' +
        'e, 0) = 1))'
      '  order by 2')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_TownsAfterOpen
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 12
    Top = 78
    oFetchAll = True
    object ds_HousesID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_HousesHOUSE_NUM: TFIBStringField
      FieldName = 'HOUSE_NUM'
      Size = 22
      EmptyStrToNull = True
    end
  end
  object dsc_Apparts: TDataSource
    DataSet = ds_Apparts
    Left = 260
    Top = 84
  end
  object ds_Apparts: TpFIBDataSet
    SelectSQL.Strings = (
      
        'select distinct coalesce(a.apparts,'#39'0'#39')||coalesce('#39#1083'.'#39'||a.letter' +
        ', '#39#39') as flat_num'
      '  from abonents a'
      '  where a.building_id = :pbuilding_id'
      '    and (a.is_active = 1 or coalesce(:pis_not_active, 0) = 1)'
      '    and a.client_id >= 0'
      '  order by a.apparts, a.letter')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_TownsAfterOpen
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 244
    Top = 8
    oFetchAll = True
    object ds_AppartsFLAT_NUM: TFIBStringField
      FieldName = 'FLAT_NUM'
      Size = 14
      EmptyStrToNull = True
    end
  end
  object ds_Abonent: TpFIBDataSet
    SelectSQL.Strings = (
      
        'select a.id, a.name, a.g_licschet, a.phone, iif(a.is_active = 0,' +
        ' '#39#1047#1072#1082#1088#1099#1090#39', '#39#39') as is_active'
      '  from v_abons a'
      '  where a.building_id = :pbuilding_id'
      '    and (a.is_active = 1 or coalesce(:pis_not_active, 0) = 1)'
      
        '    and coalesce(a.apparts,'#39'0'#39')||coalesce('#39#1083'.'#39'||a.letter, '#39#39') = ' +
        ':pflat_num'
      ''
      '    and a.client_id > -1'
      '  order by a.name, a.is_active desc')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_TownsAfterOpen
    AfterScroll = ds_AbonentAfterScroll
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 48
    Top = 8
    oFetchAll = True
    object ds_AbonentID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_AbonentNAME: TFIBStringField
      DisplayLabel = #1050#1074#1072#1088#1090#1080#1088#1086#1074#1098#1077#1084#1097#1080#1082
      DisplayWidth = 30
      FieldName = 'NAME'
      Size = 1000
      EmptyStrToNull = True
    end
    object ds_AbonentG_LICSCHET: TFIBStringField
      DisplayLabel = #8470' '#1051#1057
      DisplayWidth = 16
      FieldName = 'G_LICSCHET'
      EmptyStrToNull = True
    end
    object ds_AbonentPHONE: TFIBStringField
      FieldName = 'PHONE'
      EmptyStrToNull = True
    end
    object ds_AbonentIS_ACTIVE: TFIBStringField
      DisplayLabel = #1040#1082#1090#1080#1074#1085#1086#1089#1090#1100' '#1051#1057
      DisplayWidth = 10
      FieldName = 'IS_ACTIVE'
      Size = 6
      EmptyStrToNull = True
    end
  end
  object dsc_Abonent: TDataSource
    DataSet = ds_Abonent
    Left = 4
    Top = 44
  end
  object ds_SearchAbon: TpFIBDataSet
    SelectSQL.Strings = (
      'select first(1) a.id, a.name, a.g_licschet, a.phone,'
      
        '       coalesce(a.apparts,'#39#39')||coalesce(a.letter, '#39#39') as flat_nu' +
        'm,'
      '       a.town_id, a.street_id, a.building_id'
      '  from v_abons a'
      '  where (a.is_active = 1 or coalesce(:pis_not_active, 0) = 1)'
      '    and a.client_id > -1'
      '    @@pnls@'
      '    @@pphone@'
      '  order by a.name')
    AfterClose = ds_TownsAfterClose
    AfterOpen = ds_SearchAbonAfterOpen
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 388
    Top = 16
    oFetchAll = True
    object ds_SearchAbonID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_SearchAbonNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 120
      EmptyStrToNull = True
    end
    object ds_SearchAbonG_LICSCHET: TFIBStringField
      FieldName = 'G_LICSCHET'
      EmptyStrToNull = True
    end
    object ds_SearchAbonPHONE: TFIBStringField
      FieldName = 'PHONE'
      EmptyStrToNull = True
    end
    object ds_SearchAbonFLAT_NUM: TFIBStringField
      FieldName = 'FLAT_NUM'
      Size = 14
      EmptyStrToNull = True
    end
    object ds_SearchAbonTOWN_ID: TFIBIntegerField
      FieldName = 'TOWN_ID'
    end
    object ds_SearchAbonSTREET_ID: TFIBIntegerField
      FieldName = 'STREET_ID'
    end
    object ds_SearchAbonBUILDING_ID: TFIBIntegerField
      FieldName = 'BUILDING_ID'
    end
  end
  object dsc_SearchAbon: TDataSource
    DataSet = ds_SearchAbon
    Left = 420
    Top = 16
  end
  object ActionList: TActionList
    Left = 42
    Top = 56
    object aCloseForm: TAction
      SecondaryShortCuts.Strings = (
        'Esc')
      OnExecute = aCloseFormExecute
    end
  end
  object PropStorage: TPropStorageEh
    Section = 'dlgSelectAbonent'
    StorageManager = MAIN.IniPropStorage
    StoredProps.Strings = (
      '<P>.Left'
      '<P>.Top'
      'gbAddress.lcbClientName.<P>.DropDownBox.Width'
      'gbAddress.lcbStreets.<P>.DropDownBox.Width'
      'gbAddress.lcbTowns.<P>.DropDownBox.Width')
    Left = 280
    Top = 8
  end
end
